package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlsboolPK.
 */
@Configurable
@Embeddable
@RooIdentifier(dbManaged = true)
public final class TtlsboolPK implements java.io.Serializable {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** The qnu numitem. */
	@Column(name = "QNU_NUMITEM", columnDefinition = "DECIMAL", nullable = false)
    private BigDecimal qnuNumitem;

	/** The tim orden. */
	@Column(name = "TIM_ORDEN", columnDefinition = "TIMESTAMP", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "M-")
    private Date timOrden;

	/** The qnu orden. */
	@Column(name = "QNU_ORDEN", columnDefinition = "SMALLINT", nullable = false)
    private Short qnuOrden;

	/**
	 * Instantiates a new ttlsbool pk.
	 *
	 * @param qnuNumitem the qnu numitem
	 * @param timOrden the tim orden
	 * @param qnuOrden the qnu orden
	 */
	public TtlsboolPK(BigDecimal qnuNumitem, Date timOrden, Short qnuOrden) {
        super();
        this.qnuNumitem = qnuNumitem;
        this.timOrden = timOrden;
        this.qnuOrden = qnuOrden;
    }

	/**
	 * Instantiates a new ttlsbool pk.
	 */
	@SuppressWarnings("unused")
	private TtlsboolPK() {
        super();
    }

	/**
	 * Gets the qnu numitem.
	 *
	 * @return the qnu numitem
	 */
	public BigDecimal getQnuNumitem() {
        return this.qnuNumitem;
    }

	/**
	 * Gets the tim orden.
	 *
	 * @return the tim orden
	 */
	public Date getTimOrden() {
        return this.timOrden;
    }

	/**
	 * Gets the qnu orden.
	 *
	 * @return the qnu orden
	 */
	public Short getQnuOrden() {
        return this.qnuOrden;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlsboolPK)) return false;
        TtlsboolPK other = (TtlsboolPK) obj;
        if (qnuNumitem == null) {
            if (other.qnuNumitem != null) return false;
        } else if (!qnuNumitem.equals(other.qnuNumitem)) return false;
        if (timOrden == null) {
            if (other.timOrden != null) return false;
        } else if (!timOrden.equals(other.timOrden)) return false;
        if (qnuOrden == null) {
            if (other.qnuOrden != null) return false;
        } else if (!qnuOrden.equals(other.qnuOrden)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (qnuNumitem == null ? 0 : qnuNumitem.hashCode());
        result = prime * result + (timOrden == null ? 0 : timOrden.hashCode());
        result = prime * result + (qnuOrden == null ? 0 : qnuOrden.hashCode());
        return result;
    }

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlsbool pk.
	 *
	 * @param json the json
	 * @return the ttlsbool pk
	 */
	public static TtlsboolPK fromJsonToTtlsboolPK(String json) {
        return new JSONDeserializer<TtlsboolPK>().use(null, TtlsboolPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlsboolPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlsbool p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlsboolPK> fromJsonArrayToTtlsboolPKs(String json) {
        return new JSONDeserializer<List<TtlsboolPK>>().use(null, ArrayList.class).use("values", TtlsboolPK.class).deserialize(json);
    }
}
